package cn.liyicun.cp.cpweb.task;

import cn.liyicun.cp.cpweb.mapper.ext.ExtExpectInfoMapper;
import cn.liyicun.cp.cpweb.service.SettingInfoService;
import cn.liyicun.cp.cpweb.service.cp.GetApicpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
public class ApicpTask {
    @Autowired
    GetApicpService getApicpService;

    @Autowired
    private SettingInfoService settingInfoService;
    @Autowired
    private ExtExpectInfoMapper extExpectInfoMapper;

    @Scheduled(initialDelay = 500, fixedDelay = 3 * 1000L)
    public void run() {

//        Map<String, String> map = settingInfoService.mapCache("apicp");
//        String url = MapUtil.getStr(map, "url");
//        String codes = MapUtil.getStr(map, "code");
//        String token = MapUtil.getStr(map, "token");
//        String num = MapUtil.getStr(map, "num");
//        String[] strs = codes.split(",");
//        for (String code : strs) {
//
//           String url1 = String.format(url, token, code, num);
//            //http://www.apicp.cn/Home/Lottery/index/token/%s/code/%s/format/json/num/%s
//            // String url = "http://www.apicp.cn/Home/Lottery/index/token/" + token + "/code/" + code + "/format/json/num/" + num;
//            getApicpService.execute(code, url1);
//        }


        extExpectInfoMapper.updateByclose();
    }
}
